<?php require('connections/con_gl.php'); ?>
<?php
cekAkses($_SESSION[akses],"DD-7-2");

mysql_select_db($database_con_gl, $con_gl);
$query_klas1 = "SELECT id, gudang FROM gl_gudang ORDER BY gudang ASC";
$klas1 = mysql_query($query_klas1, $con_gl) or die(mysql_error());
$row_klas1 = mysql_fetch_assoc($klas1);
$totalRows_klas1 = mysql_num_rows($klas1);

$colname_edit = "-1";
if (isset($_GET['id'])) {
  $colname_edit = (get_magic_quotes_gpc()) ? $_GET['id'] : addslashes($_GET['id']);
}
mysql_select_db($database_con_gl, $con_gl);
$query_edit = sprintf("SELECT * FROM gl_kontak WHERE id = %s", $colname_edit);
$edit = mysql_query($query_edit, $con_gl) or die(mysql_error());
$row_edit = mysql_fetch_assoc($edit);
$totalRows_edit = mysql_num_rows($edit);
?>
<link href="ccss/ui.datepicker.css" type="text/css" rel="stylesheet" />
<script type="text/javascript" src="js/ui.datepicker.js"></script>
<script type="text/javascript">

function checktipecustomer(val) {
	if(val=='Corporate') {
		document.getElementById('jeniskelamin').value=null;	
		document.getElementById('jeniskelamin').disabled='disabled';		
		document.getElementById('tempatlahir').value=null;	
		document.getElementById('tempatlahir').disabled='disabled';		
		document.getElementById('tgllahir').value=null;	
		document.getElementById('tgllahir').disabled='disabled';		
	}else{
		document.getElementById('jeniskelamin').disabled='';		
		document.getElementById('tempatlahir').disabled='';		
		document.getElementById('tgllahir').disabled='';		
	}
}

<!--
$(function()
      {
        $('.calendar').datepicker({
            appendText : "",
            dateFormat : 'yy/mm/dd'
          });
      });
	  
</script>
<script type="text/javascript" src="js/ajax_data.js"></script>
<script type="text/javascript">
$(document).ready(function() {

	$().ajaxStart(function() {
		$('#loading').show();
		$('#result').hide();
	}).ajaxStop(function() {
		$('#loading').hide();
		$('#result').fadeIn('slow');
	});

	$('#edit').submit(function() {
		$.ajax({
			type: 'POST',
			url: $(this).attr('action'),
			data: $(this).serialize(),
			success: function(data) {
				$('#result').html(data);
			}
		})
		return false;
	});
  $('#result').click(function(){
  $(this).hide();
  });
})
</script>
<script>
function sendRespondCabang() {
	var ajaxRequest;  // The variable that makes Ajax possible!
	try{
		// Opera 8.0+, Firefox, Safari
		ajaxRequest = new XMLHttpRequest();
	} catch (e){
		// Internet Explorer Browsers
		try{
			ajaxRequest = new ActiveXObject("Msxml2.XMLHTTP");
		} catch (e) {
			try{
				ajaxRequest = new ActiveXObject("Microsoft.XMLHTTP");
			} catch (e){
				// Something went wrong
				alert("Your browser broke!");
				return false;
			}
		}
	}
	// Create a function that will receive data sent from the server
	ajaxRequest.onreadystatechange = function(){
		if(ajaxRequest.readyState == 4){
			var ajaxDisplay = document.getElementById('divJenis');
			ajaxDisplay.innerHTML = ajaxRequest.responseText;
		}
		if (ajaxRequest.readyState == 3) {
			var ajaxDisplay = document.getElementById('divJenis');
			ajaxDisplay.innerHTML = "<img src='images/ajax-loader.gif' />";
		}
	}
	ajaxRequest.open("GET", "include/send_respondcabang.php", true);
	ajaxRequest.send(null);	
}
</script>

<div id="loading" style="display:none;"><img src="images/loading.gif" alt="loading..." /></div>
<div id="result" style="display:none;"></div>
<h1>Edit Data Customer Retail </h1>
<form action="proses/customerretail.php?act=edit" method="POST" name="edit" id="edit" >
  <table width="100%" border="0" align="center" cellpadding="5" cellspacing="0">
    <tr>
      <td align="right">&nbsp;</td>
      <td align="right" bgcolor="#DDDDDD"><div align="left">Biodata Customer </div></td>
      <td bgcolor="#DDDDDD">&nbsp;</td>
      <td bgcolor="#FFFFFF">&nbsp;</td>
      <td bgcolor="#DDDDDD">Status Customer </td>
      <td bgcolor="#DDDDDD">&nbsp;</td>
      <td bgcolor="#FFFFFF">&nbsp;</td>
    </tr>
    <tr>
      <td align="right" bgcolor="#FFFFFF">&nbsp;</td>
      <td align="right" valign="top" bgcolor="#FFFFFF">TIPE CUSTOMER </td>
      <td valign="top" bgcolor="#FFFFFF"><select name="tretail" id="tretail" onchange="checktipecustomer(this.value);" style="width:180px;">
        <option value="Personal" selected="selected" <?php if (!(strcmp("Personal", $row_edit['tretail']))) {echo "selected=\"selected\"";} ?>>Personal</option>
        <option value="Corporate" <?php if (!(strcmp("Corporate", $row_edit['tretail']))) {echo "selected=\"selected\"";} ?>>Corporate</option>
      </select></td>
      <td bgcolor="#FFFFFF">&nbsp;</td>
      <td width="18%" bgcolor="#FFFFFF"><div align="right">Tanggal Daftar : </div></td>
      <td width="24%" bgcolor="#FFFFFF"><input name="tgldaftar" type="text" class="calendar" id="tgldaftar" value="<?php echo $row_edit['tgldaftar']; ?>" size="15" maxlength="15"/></td>
      <td bgcolor="#FFFFFF">&nbsp;</td>
    </tr>
    <tr>
      <td width="7%" align="right" bgcolor="#FFFFFF">&nbsp;</td>
      <td align="right" valign="top" bgcolor="#FFFFFF">Nama* : </td>
      <td valign="top" bgcolor="#FFFFFF"><label>
        <input name="nama" type="text" id="nama" value="<?php echo $row_edit['nama']; ?>" size="37" maxlength="100" />
      </label></td>
      <td width="1%" bgcolor="#FFFFFF">&nbsp;</td>
      <td valign="top" bgcolor="#FFFFFF"><div align="right">Daftar di Area : </div></td>
      <td valign="top" bgcolor="#FFFFFF"><input type="hidden" name="area" id="area" value="<?php echo $row_edit['area']; ?>" />
        <?php list($namaarea) = mysql_fetch_row(mysql_query("select area from gl_area where id = '$row_edit[area]'"));?>
        <input type="text" name="txtarea" id="txtarea" readonly="readonly" value="<?php echo $namaarea; ?>" size="20" style="background-color:#fff;border:1px solid #999; height:16px;" onclick="NewWindow('index.php?component=area&amp;task=list&amp;open=window','name','825','450','yes');return false" />
        <?php if(strstr($_SESSION['akses'],"PD-6-1")) { ?>
        <a href="index.php?component=area&amp;task=add&amp;open=window" onclick="NewWindow(this.href,'name','825','450','yes');return false"><img src="images/add_.png" alt="Tambah data Area" hspace="2" border="0" style="position:absolute;" /></a>
        <?php } ?></td>
      <td width="11%" bgcolor="#FFFFFF">&nbsp;</td>
    </tr>
    <tr valign="top">
      <td align="right" bgcolor="#FFFFFF">&nbsp;</td>
      <td align="right" bgcolor="#FFFFFF">Jenis Kelamin : </td>
      <td bgcolor="#FFFFFF"><select name="jeniskelamin" id="jeniskelamin" style="width:180px;">
          <option value="PRIA" selected="selected" <?php if (!(strcmp("PRIA", $row_edit['jeniskelamin']))) {echo "selected=\"selected\"";} ?>>PRIA</option>
          <option value="WANITA" <?php if (!(strcmp("WANITA", $row_edit['jeniskelamin']))) {echo "selected=\"selected\"";} ?>>WANITA</option>
      </select></td>
      <td bgcolor="#FFFFFF">&nbsp;</td>
      <td bgcolor="#FFFFFF"><div align="right">Daftar di Cabang: </div></td>
      <td bgcolor="#FFFFFF"><label id="divJenis">
        <input type="hidden" name="cabang" id="cabang" value="<?php echo $row_edit['cabang']; ?>" />
	  <?php list($namacabang) = mysql_fetch_row(mysql_query("select gudang from gl_gudang where id = '$row_edit[cabang]'"));?>
	  <input type="text" name="txtcabang" id="txtcabang" value="<?php echo $namacabang; ?>" size="20" readonly style="background-color:#fff;border:1px solid #999; height:16px;" onclick="NewWindow('index.php?component=gudang&amp;task=list&amp;area='+document.getElementById('area').value+'&amp;open=window','name','825','450','yes');return false" />
        </label>
          <?php if(strstr($_SESSION['akses'],"PD-7-1")) { ?>
          <a href="index.php?component=gudang&amp;task=add&amp;open=window" onclick="NewWindow(this.href,'name','825','450','yes');return false"><img src="images/add_.png" alt="Tambah data Cabang" hspace="2" border="0" /></a>
          <?php } ?></td>
      <td bgcolor="#FFFFFF">&nbsp;</td>
    </tr>
    <tr valign="top">
      <td align="right" bgcolor="#FFFFFF">&nbsp;</td>
      <td align="right" bgcolor="#FFFFFF">Tempat &amp; Tanggal Lahir : </td>
      <td bgcolor="#FFFFFF"><input name="tempatlahir" type="text" id="tempatlahir" value="<?php echo $row_edit['tempatlahir']; ?>" size="18" maxlength="100" />
          <input name="tgllahir" type="text" class="calendar" id="tgllahir" value="<?php echo $row_edit['tgllahir']; ?>" size="16" maxlength="16"/></td>
      <td bgcolor="#FFFFFF">&nbsp;</td>
      <td bgcolor="#FFFFFF"><div align="right">Status Customer : </div></td>
      <td bgcolor="#FFFFFF"><select name="statuscustomer" id="status" style="width:180px;">
          <option value="AKTIF" selected="selected" <?php if (!(strcmp("AKTIF", $row_edit['status']))) {echo "selected=\"selected\"";} ?>>AKTIF</option>
          <option value="TIDAK AKTIF" <?php if (!(strcmp("TIDAK AKTIF", $row_edit['status']))) {echo "selected=\"selected\"";} ?>>TIDAK AKTIF</option>
          <option value="BLACK LIST" <?php if (!(strcmp("BLACK LIST", $row_edit['status']))) {echo "selected=\"selected\"";} ?>>BLACK LIST</option>
      </select></td>
      <td bgcolor="#FFFFFF">&nbsp;</td>
    </tr>
    <tr valign="top">
      <td align="right" bgcolor="#FFFFFF">&nbsp;</td>
      <td align="right" bgcolor="#FFFFFF">Alamat* : </td>
      <td rowspan="2" bgcolor="#FFFFFF"><textarea name="alamat" cols="35" rows="2" id="alamat"><?php echo $row_edit['alamat']; ?></textarea>
          <input name="id" type="hidden" id="id" value="<?php echo $row_edit['id']; ?>" /></td>
      <td bgcolor="#FFFFFF">&nbsp;</td>
      <td bgcolor="#FFFFFF"><div align="right">Keterangan : </div></td>
      <td rowspan="2" bgcolor="#FFFFFF"><textarea name="keterangan" cols="35" rows="2" id="keterangan"><?php echo $row_edit['keterangan']; ?></textarea>
          <input name="id3" type="hidden" id="id3" value="<?php echo $row_edit['id']; ?>" /></td>
      <td bgcolor="#FFFFFF">&nbsp;</td>
    </tr>
    <tr valign="top">
      <td align="right" bgcolor="#FFFFFF">&nbsp;</td>
      <td align="right" bgcolor="#FFFFFF">&nbsp;</td>
      <td bgcolor="#FFFFFF">&nbsp;</td>
      <td bgcolor="#FFFFFF">&nbsp;</td>
      <td bgcolor="#FFFFFF">&nbsp;</td>
    </tr>
    <tr valign="top">
      <td align="right" bgcolor="#FFFFFF">&nbsp;</td>
      <td align="right" bgcolor="#FFFFFF">Telp/HP* : </td>
      <td bgcolor="#FFFFFF"><input name="tlp" type="text" id="tlp" value="<?php echo $row_edit['tlp']; ?>" size="37" maxlength="100" /></td>
      <td bgcolor="#FFFFFF">&nbsp;</td>
      <td bgcolor="#DDDDDD">Data Referensi </td>
      <td bgcolor="#DDDDDD">&nbsp;</td>
      <td bgcolor="#FFFFFF">&nbsp;</td>
    </tr>
    
    <tr valign="top">
      <td align="right" bgcolor="#FFFFFF">&nbsp;</td>
      <td align="right" bgcolor="#FFFFFF">Fax : </td>
      <td bgcolor="#FFFFFF"><input name="fax" type="text" id="fax" value="<?php echo $row_edit['fax']; ?>" size="37" maxlength="100" /></td>
      <td bgcolor="#FFFFFF">&nbsp;</td>
      <td bgcolor="#FFFFFF"><div align="right">Nama Referensi : </div></td>
      <td bgcolor="#FFFFFF"><input name="nama1" type="text" id="nama1" value="<?php echo $row_edit['nama1']; ?>" size="37" maxlength="100" /></td>
      <td bgcolor="#FFFFFF">&nbsp;</td>
    </tr>
    <tr valign="top">
      <td align="right" bgcolor="#FFFFFF">&nbsp;</td>
      <td align="right" bgcolor="#FFFFFF">email : </td>
      <td bgcolor="#FFFFFF"><input name="email" type="text" id="email" value="<?php echo $row_edit['email']; ?>" size="18" maxlength="100" />
          <input name="id2" type="hidden" id="id2" value="<?php echo $row_edit['id']; ?>" />
        Format : abc@xx.com </td>
      <td bgcolor="#FFFFFF">&nbsp;</td>
      <td bgcolor="#FFFFFF"><div align="right">Alamat : </div></td>
      <td rowspan="2" bgcolor="#FFFFFF"><textarea name="alamat1" cols="35" rows="2" id="alamat1"><?php echo $row_edit['alamat1']; ?></textarea>
          <input name="id4" type="hidden" id="id4" value="<?php echo $row_edit['id']; ?>" /></td>
      <td bgcolor="#FFFFFF">&nbsp;</td>
    </tr>
    <tr valign="top">
      <td align="right" bgcolor="#FFFFFF">&nbsp;</td>
      <td align="left" bgcolor="#FFFFFF"><div align="right">NPWP : </div></td>
      <td bgcolor="#FFFFFF"><input name="npwp" type="text" id="npwp" value="<?php echo $row_edit['npwp']; ?>" size="37" maxlength="100" /></td>
      <td bgcolor="#FFFFFF">&nbsp;</td>
      <td bgcolor="#FFFFFF">&nbsp;</td>
      <td bgcolor="#FFFFFF">&nbsp;</td>
    </tr>
    <tr valign="top">
      <td align="left" bgcolor="#FFFFFF">&nbsp;</td>
      <td align="left" bgcolor="#FFFFFF"><div align="right">No. KTP*  :</div></td>
      <td bgcolor="#FFFFFF"><input name="ktp" type="text" id="ktp" value="<?php echo $row_edit['ktp']; ?>" size="37" maxlength="100" /></td>
      <td bgcolor="#FFFFFF">&nbsp;</td>
      <td bgcolor="#FFFFFF"><div align="right">Telp/HP .: </div></td>
      <td bgcolor="#FFFFFF"><input name="tlp1" type="text" id="tlp1" value="<?php echo $row_edit['tlp1']; ?>" size="37" maxlength="100" /></td>
      <td bgcolor="#FFFFFF">&nbsp;</td>
    </tr>
    <tr valign="top">
      <td align="left" bgcolor="#FFFFFF">&nbsp;</td>
      <td align="left" bgcolor="#FFFFFF"><div align="right">Masa berlaku KTP* : </div></td>
      <td bgcolor="#FFFFFF"><input name="masaberlakuktp" type="text" class="calendar" id="masaberlakuktp" value="<?php echo $row_edit['masaberlakuktp']; ?>" size="20" maxlength="15"/></td>
      <td bgcolor="#FFFFFF">&nbsp;</td>
      <td bgcolor="#FFFFFF">&nbsp;</td>
      <td bgcolor="#FFFFFF">&nbsp;</td>
      <td bgcolor="#FFFFFF">&nbsp;</td>
    </tr>
    <tr valign="top">
      <td align="left" bgcolor="#FFFFFF">&nbsp;</td>
      <td align="left" bgcolor="#FFFFFF">&nbsp;</td>
      <td bgcolor="#FFFFFF">&nbsp;</td>
      <td bgcolor="#FFFFFF">&nbsp;</td>
      <td bgcolor="#FFFFFF">&nbsp;</td>
      <td bgcolor="#FFFFFF">&nbsp;</td>
      <td bgcolor="#FFFFFF">&nbsp;</td>
    </tr>
    
    <tr>
      <td align="left" bgcolor="#FFFFFF">&nbsp;</td>
      <td align="left" bgcolor="#FFFFFF"><em>*Harus diisi</em></td>
      <td bgcolor="#FFFFFF"><label>
        <input name="Save" type="submit" id="Save" value="Simpan" />
        </label>
          <label>
          <input type="button" name="Button" value="Batal" onClick="javascript:history.go(-1);">
        </label></td>
      <td bgcolor="#FFFFFF">&nbsp;</td>
      <td bgcolor="#FFFFFF">&nbsp;</td>
      <td bgcolor="#FFFFFF">&nbsp;</td>
      <td bgcolor="#FFFFFF">&nbsp;</td>
    </tr>
  </table>
</form>
